﻿using System;
namespace Producers.Liiklusregister.Xtee.Riik.Ee.Producer.Liiklusregister {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="soidukiAndmedRequest", Namespace="http://producers.liiklusregister.xtee.riik.ee/producer/liiklusregister", Target=typeof(SoidukiAndmedRequest))]
    public class SoidukiAndmedRequestSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected ISoidukiAndmedRequest clazz;
        
        public SoidukiAndmedRequestSerializer(ISoidukiAndmedRequest clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.RegTunnistuseNr!=null) {
                Writer.WriteStartElement("regTunnistuseNr");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.RegTunnistuseNr))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.SoidukId!=null) {
                Writer.WriteStartElement("soidukId");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "long");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdLong(((long)(clazz.SoidukId))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.RegMark!=null) {
                Writer.WriteStartElement("regMark");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.RegMark))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="regTunnistuseNr") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>soidukiAndmedRequest>regTunnistuseNr");
                }
                clazz.RegTunnistuseNr = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("regTunnistuseNr")).Value;
            }
            if (Reader.LocalName=="soidukId") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>soidukiAndmedRequest>soidukId");
                }
                clazz.SoidukId = new global::Xtee.Core.Schema.XsdLong(Reader.ReadElementString("soidukId")).Value;
            }
            if (Reader.LocalName=="regMark") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>soidukiAndmedRequest>regMark");
                }
                clazz.RegMark = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("regMark")).Value;
            }
        }
    }
}
